﻿using System;
using System.Collections.Generic;
using System.Linq;

using btmerc.API.Schemas;

namespace btmerc.API.Tech
{
    enum SupportLocations
    {
        Field,
        MobileFieldBase,
        TransportBay,
        MaintenanceFacility,
        Factory
    }

    class Maintenance
    {
        Vehicle _vehicle;
        Troop _mainTechTeam;
        SupportLocations _location;
        short _speed;
        bool _overtime;

        public Maintenance(Vehicle vehicle, IEnumerable<Troop> techTeams, SupportLocations location, short speed, bool overtime)
        {
            _location = location;
            _vehicle = vehicle;
            _speed = speed;
            _overtime = overtime;
        }

        private short TotalGlobalModifiers()
        {
            return LocationModifier();
        }

        private short TotalComponentModifiers(Component component)
        {
            throw new NotImplementedException();
            //ComponentQualityModifier()
            //ComponentTechRating()
            //if(ClanISMismatch(component))
            //if(IsExtinct(component) || IsExperimental(component))
        }

        private short TechRatingModifier(Rating rating)
        {
            switch (rating)
            {
                case Rating.A:
                    return -4;
                case Rating.B:
                    return - 2;
                case Rating.C:
                    return 0;
                case Rating.D:
                    return 1;
                case Rating.E:
                    return 2;
                case Rating.F:
                    return 3;
                default:
                    return 0;
            }
        }

        private short ComponentQualityModifier(Rating rating)
        {
            switch (rating)
            {
                case Rating.A:
                    return 3;
                case Rating.B:
                    return 2;
                case Rating.C:
                    return 1;
                case Rating.D:
                    return 0;
                case Rating.E:
                    return -1;
                case Rating.F:
                    return -2;
                default:
                    return 0;
            }
        }

        private short LocationModifier()
        {
            switch (_location)
            {
                case SupportLocations.Field:
                    return 2;
                case SupportLocations.MobileFieldBase:
                    return 1;
                case SupportLocations.TransportBay:
                    return 0;
                case SupportLocations.MaintenanceFacility:
                    return -2;
                case SupportLocations.Factory:
                    return -4;
                default:
                    return 0;
            }
        }

        private bool ClanISMismatch(Component component)
        {
            throw new NotImplementedException();
            //if IS techs and Clan component, +6
            // if Clan techs and IS component, +4
        }
    }

    class MaintenanceBill
    {
    }
}
